package predictionEngine.errorMangement;

import java.util.ArrayList;

public class ErrorManager {
    private ArrayList <ErrorHandler> errorHandlers = new ArrayList();
    private static ErrorManager errorManager;
    /** Creates a new instance of ErrorManager */
    private ErrorManager() {        
    }
    public static ErrorManager getInstance(){
        if(errorManager ==null)
            errorManager = new ErrorManager();
        return errorManager;
    }
    
    public int getNrOfErrorHandlers(){
        if(errorHandlers==null)
           return 0;
        return errorHandlers.size();
    }
    
    public void reportError(Exception e){
        if(errorHandlers.isEmpty())
            errorHandlers.add(new ErrorHandlerConsole());
        for(ErrorHandler eH : errorHandlers){
            eH.onError(e);
        }
    }
    public void addErrorhandler(ErrorHandler e){
        errorHandlers.add(e);
    }
    
}

